package com.company.nuwa.common.enumration;

/**
 * <p></p>
 *
 * @author lili
 * @version 1.0: GraphTimeTypeEnum
 * @date 2024/1/27 14:26
 */
import lombok.Getter;

/**
 * <p>description</p >
 *
 * @author zhouyu
 * @version 1.0
 * @date 2021/05/19 11:42
 */
@Getter
public enum GraphTimeTypeEnum {

    DAYALL(0, -999, "全部"),

    DAY7(1, -6, "近七天"),


    DAY15(15, -14, "近15天"),
    DAY30(2, -29, "近30天"),

    DAY90(3, -89, "近90天"),

    DAY_YESTERDAY(4, -1, "昨日"),

    DAY_TODAY(5, 0, "今天"),

    MONTH3(11, -3, "近3个月"),

    MONTH6(12, -6, "近6个月"),

    MONTH12(13, 12, "近12个月"),

    ;

    private final Integer code;
    private final Integer value;
    private final String type;

    GraphTimeTypeEnum(Integer code, Integer value, String type) {
        this.code = code;
        this.value = value;
        this.type = type;
    }

    /**
     * 获取枚举描述
     *
     * @param code
     * @return
     */
    public static String getGraphTimeTypeByCode(Integer code) {
        for (GraphTimeTypeEnum en : values()) {
            if (en.code.equals(code)) {
                return en.type;
            }
        }
        return null;
    }

    /**
     * 获取枚举
     *
     * @param code
     * @return
     */
    public static GraphTimeTypeEnum getGraphTimeTypeEnumByCode(Integer code) {
        for (GraphTimeTypeEnum en : values()) {
            if (en.code.equals(code)) {
                return en;
            }
        }
        return null;
    }
}
